package cn.txauction.web.paging;

import java.util.List;

public class PageView<T> {
	// 分页数据
	private List<T> records;
	// 页码开始索引和结束索引 
	private PageIndex pageindex;
	// 总页数
	private int totalpage = 1;
	// 每页显示记录数
	private int pagesize = 10;
	// 当前页 
	private int currentpage = 1;
	// 总记录数 
	private long totalrecord;
	// 页面导航栏显示的页面索引数量
	private int pageBarsize = 10;
	
	public PageView(int pagesize, int currentpage, 	int pageBarsize) {
		this.pagesize = pagesize;
		this.currentpage = currentpage;
		this.pageBarsize = pageBarsize;
		
	}
	public void setPagingResult(PagingResult<T> ps){
		this.setRecords(ps.getResultList());
		this.setTotalrecord(ps.getTotalRecords());
	}
	public List<T> getRecords() {
		return records;
	}
	public void setRecords(List<T> records) {
		this.records = records;
	}
	public PageIndex getPageindex() {
		return pageindex;
	}
	public void setPageindex() {
		this.pageindex = PagingWebTool.getPageIndex(pageBarsize, currentpage, totalpage);
	}
	public long getTotalpage() {
		return totalpage;
	}
	public void setTotalpage() {
		this.totalpage = new Long(totalrecord %pagesize==0?totalrecord/pagesize:totalrecord/pagesize+1).intValue();
		setPageindex();
	}

	public int getPagesize() {
		return pagesize;
	}
	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
	public int getCurrentpage() {
		return currentpage;
	}
	public void setCurrentpage(int currentpage) {
		this.currentpage = currentpage;
	}
	public long getTotalrecord() {
		return totalrecord;
	}
	public void setTotalrecord(long totalrecord) {
		this.totalrecord = totalrecord;
		setTotalpage();
	}
	public int getPageBarsize() {
		return pageBarsize;
	}
	public void setPageBarsize(int pageBarsize) {
		this.pageBarsize = pageBarsize;
	}

	
	
}
